// pages/Bonus/Bonus.js
var util = require('../../utils/util.js')
var app = getApp()
var rootUrl = app.globalData.rootDocment
var imgPublicUrl = rootUrl + 'Public/Home/images/'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imageArr: {
      BonusBanner: imgPublicUrl + 'BonusBanner.jpg'
    },
    money:0.00
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //获取奖励金
    this.getMymoney()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
	app.publicchangenavigate()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var ists = wx.getStorageSync('txist')
    if (ists == 1) {
      this.getMymoney()
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
	return app.globalshare();
  },
  /**
   * 奖励金记录
   */
  IncomeTap: function () {
    app.publicnavigateTologing('/pages/Bonus/Income/Income')
  },
  /**
   * 提现记录
   */
  withdrawResultTap:function(){
	  app.publicnavigateTologing('/pages/Bonus/withdrawResult/withdrawResult')
  },
  /**
   * 提现
   */
  withdrawTap: function () {
	app.publicnavigateTologing('/pages/Bonus/withdraw/withdraw')
  },
  //获取奖励金
  getMymoney:function(){
    var that = this
    var uid = app.globalData.userInfoId
    //开启加载
    that.setData({ submitload: true })
    //提交给服务端
    util.AJAX('Home/Troops/getMymoney', { uid: uid }, function (res) { //方法体
      //关闭加载
      that.setData({ submitload: false })
      if (res.data.StatusCode == 200) {  //成功
          that.setData({ money: res.data.Moneys })
      } else {	//失败

      }
    }, 'POST')
  }
})